home *** CD-ROM | disk | FTP | other *** search
- From bobp@amiga.UUCP (Robert S. Pariseau) Fri Nov 8 13:00:10 1985
- Path: gumby!uwvax!seismo!caip!topaz!packard!hoxna!houxm!ihnp4!nsc!pyramid
- !amiga!bobp
- From: bobp@amiga.UUCP (Robert S. Pariseau)
- Newsgroups: net.micro.amiga
- Subject: Sampled Sounds File Format
- Date: 8 Nov 85 19:00:10 GMT
- Reply-To: bobp@snake.UUCP (Robert S. Pariseau)
- Organization: Commodore-Amiga Inc., 983 University Ave #D, Los Gatos CA 95030
-
- I've received some mail asking for this stuff, so here's a copy of a
- posting I made to BIX recently:
-
- =================================
-
- TITLE: Sampled Sound Data Files
-
- This note (ahem) describes the format of the sampled sound data files found
- on the instruments disk which is used with the Music demo on the dealer's
- Workbench Demo Disk. This stuff is lifted from the musty files of
- Sam-the-audio-expert. If you don't understand some of the terminology used,
- you're out of luck until Sam-tae returns from vacation.
-
- I've looked at the source for the Music demo and, like all our demo code (see
- comment elsewhere in this conference), it's full of bees and spiders! That's
- why we don't give it out. In any event, I'll do my best to guide you. Hold
- on tightly now....
-
- Each sampled sound begins with the CompressedSample header described below.
- Each sound is comprised of one or more octaves. Each octave is comprised of
- one or more segments. A segment contains 2**N cycles of the waveform in
- tune, usually bounded by zero crossings. The sampled sound may designate the
- ending segments as looping segments. The looping and unlooping segments are
- not to be confused with an envelope or ADSR. An ADSR envelope is independent
- and controlled with variables in the Note structure. These segments will be
- played repeatedly during the Sustain and Release of the note.
-
- Each octave's segment size is twice as large as the octave above it.
-
- Example:
-
- highOctSize = 4;
- lowOctSize = 7;
- numSegments = 5;
- loopStart = 3;
-
- If each digit below represents 16 bytes of data, then each segment would take
- the space indicated by the number of digits with the segment number.
- Segments 3 & 4 of an octave would be repeated for looping.
-
- ____
- / \ loop
- V |
- 012340011223344000011112222333344440000000011111111222222223333333344444444
- \ /\__ __/\___________________/\_______________ _______________/
- \ / \ / \ /
- highest next lowest
- octave octave octave
-
- <--low memory . . . high memory-->
-
- The notes for a given octave are produced by playing the sample for that
- octave at a sampling rate of between 14 and 28KHz (one octave). The Music
- demo uses a trivial Vertical Blank Interrupt Server to signal it regularly
- once per video frame. These "ticks" are used to advance through the ADSR
- envelope described in the Note structure. Envelope generation is done by
- issuing the appropriate audio device command to change audio channel volume.
-
- The actual period values used to produce the scale are
- 240, 226, 214, 202, 190, 180, 170, 160, 151, 143, 135, 127.
-
- The meanings of Very Slow to Very Fast attack, decay, and release are built
- into the Music demo -- as are the default settings of these for each
- instrument. Sustain is determined by how long the player keeps the key
- depressed.
-
- For more info on all of this, refer to the Amiga Hardware Manual and the
- Amiga ROM Kernel Manual.
-
- --------------------------Sampled sound header file
-
- /* The looping octaves technique number */
- #define TL_LOOPING_OCTAVES 1
-
- #define MAX_SAMPLE_SIZE (sizeof(struct CompressedSample)+2*128*128)
-
-
- /* compressed sampled sound data structure */
-
- /* THIS IS THE HEADER ON A SAMPLED SOUND DATA FILE */
-
- struct CompressedSample {
- UWORD technique; /* technique number */
- UWORD numSegments; /* number of segments in sample (same for all octaves)*/
- UWORD loopStart; /* first segment of loop (= numSegments for no loop) */
- UBYTE highOctSize; /* highest octave segment size (power of 2) */
- UBYTE lowOctSize; /* lowest octave segment size (power of 2) */
- BYTE samples[1]; /* start of samples */
- };
-
- /* note descriptor */
-
- /* THIS STRUCTURE IS USED TO KEEP ADSR INFO WITH A SOUND IN MEMORY */
-
- struct Note {
- struct CompressedSample *sample; /* sound sample in compressed format */
- UWORD attack; /* attack time in msec. (0 - 65535) */
- UWORD decay; /* decay time in msec., 0 for sustain (1 - 65535) */
- UWORD release; /* release time in msec. (0 - 65535) */
- UBYTE channel; /* audio channel number (0 - 3) */
- UBYTE pitch; /* note number, 0 for A (0 - highest octave of sound) */
- UBYTE level; /* sustain level in 0.1875 db steps (0 - 255) */
- UBYTE vibDepth; /* vibrato depth, up to one whole step (0 - 255) */
- UBYTE vibRate; /* vibrato rate, (0 - 255) */
- };
-
-